package leetcode_1601_1700;

public class LeeCode_1615 {
    public static void main(String[] args) {
        System.out.println(maximalNetworkRank(4, new int[][]{{0, 1}, {0, 3}, {1, 2}, {1, 3}}));
        System.out.println(maximalNetworkRank(8, new int[][]{{0, 1}, {1, 2}, {2, 3}, {2, 4},{5,6},{5,7}}));
    }
    private static int maximalNetworkRank(int n, int[][] roads) {
        int len = roads.length;
        int max = 0;
        for (int i = 0; i < n; i++) {
            for (int k = i; k < n; k++) {
                int count = 0;
                for (int j = 0; j < len; j++) {
                    if (roads[j][0] == i || roads[j][1] == i || roads[j][0] == k || roads[j][1] == k){
                        count++;
                    }
                }
                max = Math.max(count, max);
            }
        }
        return max;
    }
}
